package 单例模式.禁止重排序单例模式;

public class Singleton {
    private static volatile Singleton instance=null;
    private Singleton(){}
    public Singleton getInstance(){
        if(instance==null){
            synchronized (instance){
                if(instance==null) instance=new Singleton();
            }
        }
        return instance;
    }
}
